import pEmpty from '@/images/cart/empty-cart.png';
import { Image, View } from '@tarojs/components';
import React from 'react';
import utils, { goHomePage } from '@/utils/index';
import Taro from '@tarojs/taro';
import { getDispatch } from '../../../../dva';

import styles from './index.module.scss';

const EmptyCart = () => {
  const token = utils.getToken();

  const handleGo = () => {
    if (!token) {
      Taro.navigateTo({
        url: '/pages/other/login/index',
      });
    } else {
      goHomePage(getDispatch());
    }
  };

  return (
    <View className={styles.EmptyCart}>
      <Image className="img" src={pEmpty} />
      <View className="notice">千万好物等您挑选</View>

      <View className="action customePageBackgroundStyle" onClick={handleGo}>
        <View className="txt">{!token ? '登录并查看购物车' : '暂无商品，快去逛逛吧～'}</View>
      </View>
    </View>
  );
};

export default EmptyCart;
